package com.briup.cms.service.impl;

import com.briup.cms.bean.User;
import com.briup.cms.bean.extend.UserExtend;
import com.briup.cms.dao.UserMapper;
import com.briup.cms.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class UserServiceImpl implements IUserService {
  @Resource
  private UserMapper userMapper;

    @Override
    public List<User> findAll() {
     return userMapper.selectAll();
    }

    @Override
    public void saveOrUpdate(User user) {
        if(user.getId()!=null){
           userMapper.update(user);
        }else{
            userMapper.insert(user);}
    }

    @Override
    public void deleteById(Long id) {
        userMapper.delete(id);
    }

    @Override
    public List<User> queryById(Long id) {
        return userMapper.selectInId(id);
    }

    @Override
    public List<UserExtend> findAllWithRole() {
        return userMapper.selectAllWithRole();
    }


}
